﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Wuliu.SDK.Core.Client;
using Wuliu.SDK.Core.Model;
using Wuliu.SDK.Web.Models;

namespace Wuliu.SDK.Web.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;
        private readonly WuliuConfig _wuliu;

        public HomeController(ILogger<HomeController> logger, IOptionsMonitor<WuliuConfig> config)
        {
            _logger = logger;
            _wuliu = config.CurrentValue;
        }

        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Privacy()
        {
            var client = new DeBangClient(_wuliu.DeBang.appkey, _wuliu.DeBang.companyCode);
            


            StandTraceSubscribe request = new StandTraceSubscribe();
            request.tracking_number = "DPK330231552801";
            request.order_number = request.tracking_number;

            var result = client.GetStandTraceSubscribe(request).Result;


            return View();
        }

        

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
